package net.flintx.array;

/**
 * Created by flintx on 2018/1/10.
 */
public class MaxConsecutiveOnes {
    public int findMaxConsecutiveOnes(int[] nums) {
        int maxCount = 0;
        int index = 0;
        while (index < nums.length) {
            int count = 0;
            while (index < nums.length && nums[index] == 1) {
                index += 1;
                count += 1;
            }
            maxCount = Math.max(count, maxCount);
            index += 1;
        }
        return maxCount;
    }

    public static void main(String[] args) {
        int[] nums = {1,1,0,1,1,1,0,0,1,1,1,1,1,1,1,0};
        System.out.println(new MaxConsecutiveOnes().findMaxConsecutiveOnes(nums));
    }
}
